Skip to content

cli: hint when install-runner options are ignored#938

Open
YasharthPanwar-2003 wants to merge 1 commit into
docker:mainfrom
YasharthPanwar-2003:fix-install-runner-existing-options
Open

cli: hint when install-runner options are ignored#938
YasharthPanwar-2003 wants to merge 1 commit into
docker:mainfrom
YasharthPanwar-2003:fix-install-runner-existing-options

Conversation

@YasharthPanwar-2003
Copy link
Copy Markdown

Summary

  • Add a reinstall hint when install-runner finds an existing running Model Runner container
  • Show the hint only when the user explicitly passed --backend or --gpu
  • Preserve the existing “already running” message and return behavior
  • Add focused tests for the new hint-generation logic

Fixes #907

What changed

  • Added commandFlagChanged to check whether a Cobra flag was explicitly changed
  • Added existingRunnerOptionsHint to build the reinstall command hint
  • Updated the existing ctrID != "" branch to print the hint after the current already-running message
  • Added cmd/cli/commands/install_runner_existing_options_hint_test.go

What this does not change

  • Does not automatically reinstall or recreate an existing runner
  • Does not change reinstall-runner behavior
  • Does not change backend selection logic
  • Does not change GPU probing or CUDA/vLLM runtime behavior
  • Does not attempt to fully fix WSL2 CUDA/vLLM execution

Tests added

  • No hint when --backend and --gpu were not explicitly passed
  • Backend-only hint
  • GPU-only CUDA hint
  • Backend + CUDA hint
  • Explicit --gpu none hint
  • Defensive flag-check cases

Validation

  • go test ./cmd/cli/commands -run "TestInstallRunner|TestExistingRunnerOptionsHint|TestCommandFlagChanged" -v
  • go test ./cmd/cli/commands -v`
  • go test ./...
  • make validate-all

Validation details

  • go.mod tidy check passed
  • golangci-lint run ./... passed with 0 issues
  • go test -race ./... passed
  • Shellcheck validation passed
  • .versions is in sync with Dockerfile ARGs

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to provide users with a hint command when they attempt to install or start a Model Runner that is already active but with different configuration flags. It includes a new helper function to detect flag changes and comprehensive unit tests for the hint generation logic. Feedback was provided regarding a potential security and correctness issue where user-provided flag values are not properly escaped in the suggested command string, which could lead to issues if values contain spaces or malicious characters.

Comment on lines +266 to +271
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", opts.backend)
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", opts.gpuMode)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

Critical

  • The suggested command string is constructed using unvalidated and unescaped user input from flags. This poses a security risk (command injection if a user copy-pastes a malicious string) and a correctness issue if values contain spaces. Values should be properly quoted/escaped for the shell.

Following the Security principle (Repository Style Guide, line 12), input must be handled safely when crossing boundaries, including when displayed back to the user as a suggested command.

Suggested change
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", opts.backend)
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", opts.gpuMode)
}
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", fmt.Sprintf("%q", opts.backend))
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", fmt.Sprintf("%q", opts.gpuMode))
}

@@ -0,0 +1,126 @@
package commands
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better if you can put the tests in existing install-runner_test.go file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok , I do that. May you please help me with if the gemini suggested changes to be done in code ?

Copy link
Copy Markdown
Contributor

@sathiraumesh sathiraumesh May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YasharthPanwar-2003 if you check the code both of theopts.backend and the opts.gpuMode are validated by predefined sepcs. so it won't be a problem though but for defense in future its better to do the suggestion by gemini here like change to the below


if backendChanged && opts.backend != "" {
		reinstallArgs = append(reinstallArgs, "--backend", fmt.Sprintf("%q", opts.backend))
	}
	if gpuChanged && opts.gpuMode != "" {
		reinstallArgs = append(reinstallArgs, "--gpu", fmt.Sprintf("%q", opts.gpuMode))
	}

Its always important to double check what these analyzers suggest because it sometimes can be wrong. Always try to check whether its the case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and test this feature in local as well :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont have NVIDIA gpu cuda , but I tested it over wsl2 Ubuntu 22.04 for cpu only , after the new updation I will test again!

@ericcurtin
Copy link
Copy Markdown
Contributor

@YasharthPanwar-2003 thanks for looking at this, is the bot comment worth fixing?

@ericcurtin
Copy link
Copy Markdown
Contributor

You will need to fix CI also

@YasharthPanwar-2003 YasharthPanwar-2003 force-pushed the fix-install-runner-existing-options branch 2 times, most recently from 01003e8 to 6b57737 Compare May 26, 2026 01:58
@YasharthPanwar-2003
Copy link
Copy Markdown
Author

Updated the PR based on review feedback.

Summary:

  • Moved the new hint tests into the existing install-runner test file.
  • Quoted displayed backend/GPU values in the suggested reinstall command.
  • Added a defensive test for quoted flag values.
  • Updated CI and the model-cli validation workflow to avoid the matrix subaction that pulled an unpinned transitive action, while keeping the prepare job.

Manual verification:

  • Verified Docker Desktop Model Runner works on WSL2 Ubuntu 22.04 with a CPU model:
    docker model run ai/smollm2 "Say hello in one short sentence."
  • Verified the local edited CLI prints the new hint when an existing docker-model-runner container is already running:
    • --gpu none suggests docker model reinstall-runner --gpu "none"
    • --backend vllm suggests docker model reinstall-runner --backend "vllm"
    • --backend vllm --gpu cuda suggests docker model reinstall-runner --backend "vllm" --gpu "cuda"

Validation:

  • Focused install-runner tests passed on WSL2 Ubuntu 22.04.
  • Focused install-runner tests passed on Windows 11.
  • Docker Bake validate-docs and validate-tests targets printed correctly.
  • Full make validate-all passed on WSL2 Ubuntu 22.04

I do not have NVIDIA CUDA hardware, so I did not run the actual vLLM CUDA reinstall path. The manual test verifies the intended existing-runner hint behavior without requiring CUDA.

-
name: Generate matrix
id: generate
uses: docker/bake-action/subaction/matrix@a66e1c87e2eca0503c343edf1d208c716d54b8a8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why you change this ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The reason was the failing Validate model-cli / prepare check.

So , previously before new commit , it showed as gvien below . further , I understood to do changes in CI as per asked by ericcurtin

The failure log showed:

actions/github-script@v8 is not allowed in docker/model-runner because all actions must be pinned to a full-length commit SHA

That check comes from this workflow (Validate model-cli) and specifically the prepare job. The direct docker/bake-action/subaction/matrix reference is pinned, but the subaction path was still causing GitHub to resolve actions/github-script@v8, which is blocked by the repo/org full-SHA action policy.

GitHub documents that repositories/organizations can require actions to be pinned to a full-length commit SHA:
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository

Since cmd/cli/docker-bake.hcl currently has only two validation targets under the validate group (validate-docs and validate-tests), I replaced the dynamic matrix generation with an explicit matrix output while keeping the existing prepare and validate job structure.

If you prefer to keep the bake matrix subaction and handle this CI policy another way, I can revert the workflow change and keep this PR scoped to the install-runner behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not do this change in the CI. I think what @ericcurtin mentioned was to fix reason if any changes done from this PR breaks the CI.

Copy link
Copy Markdown
Author

@YasharthPanwar-2003 YasharthPanwar-2003 May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking same ealier . Thanks for feedback , I will undo it and keep the relevant ones .

Updated based on the review feedback.

I reverted the CI workflow change and kept this PR scoped to the install-runner behavior only.

@YasharthPanwar-2003 YasharthPanwar-2003 force-pushed the fix-install-runner-existing-options branch from 6b57737 to a2b06c5 Compare May 26, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]vllm backend doesn't work for wsl2 ubuntu22.04

3 participants